package com.ds.common.route.context;

import com.ds.common.route.config.Cluster;
import lombok.Getter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 权限校验客户端
 * @author WeiShaoying
 */
@Component
public class RuntimeClient implements InitializingBean {
    @Value("${spring.profiles.active}")
    private String env;

    @Getter
    private static Cluster cluster;

    public static RuntimeContext getRuntimeContext() {
        return RuntimeContextHolder.getContext();
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        cluster = Cluster.valueOf(env);
    }
}
